home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / var / lib / dpkg / info / initramfs-tools.preinst < prev    next >
Encoding:
Text File  |  2012-10-05  |  1.1 KB  |  46 lines

  1. #!/bin/sh
  2.  
  3. set -e
  4.  
  5. chrooted() {
  6.     # borrowed from udev's postinst
  7.     if [ "$(stat -c %d/%i /)" = "$(stat -Lc %d/%i /proc/1/root 2>/dev/null)" ]; then
  8.         # the devicenumber/inode pair of / is the same as that of
  9.         # /sbin/init's root, so we're *not* in a chroot and hence
  10.         # return false.
  11.         return 1
  12.     fi
  13.     return 0
  14. }
  15.  
  16. case "$1" in
  17.     install)
  18.         mkdir -p /etc/initramfs-tools/conf.d
  19.  
  20.         # First time install.  Can we autodetect the RESUME partition?
  21.         if [ -r /proc/swaps ]; then
  22.             RESUME=$(grep ^/dev/ /proc/swaps | sort -rk3 \
  23.                 | head -n 1 | cut -d " " -f 1)
  24.             if command -v blkid >/dev/null 2>&1; then
  25.                 UUID=$(blkid -s UUID -o value "$RESUME" || true)
  26.             # FIXME: post-Wheezy remove vol_id invocations
  27.             elif command -v vol_id >/dev/null 2>&1; then
  28.                 UUID=$(vol_id -u "$RESUME" || true)
  29.             elif [ -x /lib/udev/vol_id ]; then
  30.                 UUID=$(/lib/udev/vol_id -u "$RESUME" || true)
  31.             fi
  32.             if [ -n "$UUID" ]; then
  33.                 RESUME="UUID=$UUID"
  34.             fi
  35.         fi
  36.  
  37.         # write conf.d/resume if not in a chroot
  38.         if [ -n "${RESUME}" ] && ! chrooted; then
  39.             echo "RESUME=${RESUME}" > /etc/initramfs-tools/conf.d/resume
  40.         fi
  41.  
  42.     ;;
  43. esac
  44.  
  45.  
  46.